package cn.wolfcode.shop.cloud.mapper;

import cn.wolfcode.shop.cloud.domain.SeckillGood;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SeckillGoodMapper {
    @Select("select * from t_seckill_goods")
    List<SeckillGood> querySeckillGoods();

    @Select("select *from t_seckill_goods where id=#{seckillId}")
    SeckillGood findById(Long seckillId);

    @Update("update t_seckill_goods set stock_count = stock_count - 1 where id = #{seckillId} and stock_count>0")
    int decrCount(Long seckillId);

    @Update("update t_seckill_goods set stock_count = stock_count + 1 where id = #{goodId}")
    void incrCount(Long goodId);
}
